﻿namespace Gateway.Common.Entity
{
    public class EntityWithOperatorBase : EntityBase
    {
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatedBy { get; private set; }

        /// <summary>
        /// 创建人名称
        /// </summary>
        public string CreatorName { get; private set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; private set; }

        /// <summary>
        /// 更新人
        /// </summary>
        public string LastModifiedBy { get; private set; }

        /// <summary>
        /// 修改人名称
        /// </summary>
        public string LastModifierName { get; private set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime LastModifiedTime { get; private set; }

        #region 实体操作

        /// <summary>
        /// 添加创建人信息
        /// </summary>
        /// <param name="operatorId"></param>
        /// <param name="operatorName"></param>
        public virtual void SetCreate(string operatorId, string operatorName)
        {
            CreatedBy = operatorId;
            CreatedTime = DateTime.Now;
            CreatorName = operatorName;
            SetModifier(operatorId, operatorName);
        }

        /// <summary>
        /// 添加创建人信息
        /// </summary>
        /// <param name="operatorId"></param>
        /// <param name="operatorName"></param>
        public virtual void SetCreate(string operatorId, string operatorName, DateTime createdTime)
        {
            CreatedBy = operatorId;
            CreatedTime = createdTime;
            CreatorName = operatorName;
            SetModifier(operatorId, operatorName, createdTime);
        }

        /// <summary>
        /// 添加修改人信息
        /// </summary>
        /// <param name="operatorId"></param>
        /// <param name="operatorName"></param>
        public virtual void SetModifier(string operatorId, string operatorName)
        {
            LastModifiedBy = operatorId;
            LastModifierName = operatorName;
            LastModifiedTime = DateTime.Now;
        }

        /// <summary>
        /// 添加修改人信息
        /// </summary>
        /// <param name="operatorId"></param>
        /// <param name="operatorName"></param>
        public virtual void SetModifier(string operatorId, string operatorName, DateTime modifiedTime)
        {
            LastModifiedBy = operatorId;
            LastModifierName = operatorName;
            LastModifiedTime = modifiedTime;
        }

        #endregion


        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        public void SetDefaultId(string id)
        {
            this.Id = id;
        }
    }
}